package com.sample.thread.countDownLatch;

import java.util.concurrent.CountDownLatch;

/**
* @comments
* @author  zg
* @date 2021年3月12日
*/
public class CountThread extends Thread{
	
	private CountDownLatch counter;
	
	private String threadName;
	
	private int count;
	
	public CountThread(CountDownLatch counter, String threadName, int count) {
		this.counter = counter;
		this.threadName = threadName;
		this.count = count;
	}

	@Override
	public void run() {
		
		for (int i = 1; i <= count; i++) {
			try {
				System.out.println(threadName + "计数：" + i);
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		//
		System.out.println("-----"+threadName+"计数完毕。计数"+count + "-----");
		counter.countDown();
	}

	
}
